package com.ruoyi.system.api.domain.finance;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.domain.basedata.Customer;
import com.ruoyi.system.api.domain.basedata.Supplies;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 应收需求单对象 finer_recive_req
 *
 * @author wl
 * @date 2024-11-01
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ReciveReq implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    private Integer id;

    private Integer OrderType;
    /**
     * 单据编号
     */
    @Excel(name = "单据编号")
    private String orderCode;

    /**
     * 单据日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "单据日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date orderDate;

    /**
     * 单据阶段（2：已提交3：已审批4：执行完）
     */
    private Integer orderStatus;

    @Excel(name = "单据阶段")
    private String orderStatusName;

    /**
     * 单据类型(0:销售应收1:采购应收2:其他应收)
     */
    private Integer paymentType;

    //
    @Excel(name = "单据类型")
    private String paymentTypeName;

    /**
     * 客户id
     */
    private Integer customerId;

    //客户对象
    private Customer customer;

    @Excel(name = "客户")
    private String cusName;

    /**
     * 供货商id
     */
    private Integer supplierId;

    //供货商对象
    private Supplies supplies;

    @Excel(name = "供货商")
    private String supName;

    /**
     * 业务员
     */
    private Integer orderUserId;

    //业务员对象
    private SysUser orderUser;

    @Excel(name = "业务员")
    private String orderUserName;

    //业务部门名称
    @Excel(name = "业务部门")
    private String orderDeptName;

    /**
     * 源单号
     */
    @Excel(name = "源单号")
    private String srcOrderCode;

    /**
     * 金额
     */
    @Excel(name = "金额")
    private BigDecimal money;

    /**
     * 已核销金额
     */
    @Excel(name = "已核销金额")
    private BigDecimal verMoney;


    @Excel(name = "未结算金额")
    private BigDecimal noMoney;

    /**
     * 生效日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "生效日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date effectDate;

    /**
     * 审核人
     */
    private Integer approvalId;

    @Excel(name = "审核人")
    private String approvalUserName;

    //审核人对象
    private SysUser approvalUser;

    /**
     * 审批结果（0：无1：未审批2：已通过3：已驳回）
     */
    private Integer approvalResult;

    @Excel(name = "审批结果")
    private String approvalResultName;

    /**
     * 审核意见
     */
    @Excel(name = "审核意见")
    private String approvalOption;

    /**
     * 是否生效(0:未生效1:已生效)
     */
    private Integer isEffect;

    @Excel(name = "是否生效")
    private String isEffectName;

    /**
     * 是否关闭（0：未关闭1：已关闭）
     */
    private Integer isClose;

    private String isCloseName;

    /**
     * 是否作废（0：未作废1：已作废）
     */
    private Integer isCancel;

    private String isCancelName;

    //创建人
    @Excel(name = "创建人")
    private String createBy;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date createDate;

    /**
     * 修改人
     */
    @Excel(name = "修改人")
    private String modifyBy;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date modifyDate;

    //备注
    @Excel(name = "备注")
    private String remark;

    /**
     * 是否删除(0:未删除1:已删除)
     */
    private Integer isDel;

    /**
     * 搜索值
     */
    @JsonIgnore
    private String searchValue;

    /**
     * 请求参数
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }

    public void setApprovalResult(Integer approvalResult) {
        this.approvalResult = approvalResult;
        if (approvalResult == null) {
            return;
        }
        if (approvalResult == 0) {
            this.approvalResultName = "无";
        }
        if (approvalResult == 1) {
            this.approvalResultName = "未审批";
        }
        if (approvalResult == 2) {
            this.approvalResultName = "审核通过";
        }
        if (approvalResult == 3) {
            this.approvalResultName = "审核不通过";
        }
    }

    public void setIsEffect(Integer isEffect) {
        this.isEffect = isEffect;
        if (isEffect == null) {
            return;
        }
        if (isEffect == 0) {
            this.isEffectName = "未生效";
        }
        if (isEffect == 1) {
            this.isEffectName = "已生效";
        }
    }

    public void setIsClose(Integer isClose) {
        this.isClose = isClose;
        if (isClose == null) {
            return;
        }
        if (isClose == 0) {
            this.isCloseName = "未关闭";
        }
        if (isClose == 1) {
            this.isCloseName = "已关闭";
        }
    }

    public void setIsCancel(Integer isCancel) {
        this.isCancel = isCancel;
        if (isCancel == null) {
            return;
        }
        if (isCancel == 0) {
            this.isCancelName = "未作废";
        }
        if (isCancel == 1) {
            this.isCancelName = "已取消";
        }
    }

    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
        if (orderStatus == null) {
            return;
        } else if (orderStatus == 1) {
            this.orderStatusName = "编辑中";
        } else if (orderStatus == 2) {
            this.orderStatusName = "已提交";
        } else if (orderStatus == 3) {
            this.orderStatusName = "执行中";
        } else if (orderStatus == 4) {
            this.orderStatusName = "执行完";
        }
    }
}
